import http from "../utils/request"
//获取验证码
export let getCaptcha = () => http.get("/users/getCaptcha?v=next")

//校验验证码
export let verifyCaptcha = captcha => http.get("/users/verifyCaptcha", {
    params: {
        captcha
    }
})

//常规登入
export let loginApi = (username, password) => http.post("/users/login", {
    username,
    password
})

//获取二维码地址
export let getQrCodeApi = sid => http.get("/users/getQrcode", {
    params: {
        sid
    }
})

//微信登入
export let wechatLoginApi = wechatCode => http.get('/users/wechatLogin', {
    params: {
        wechatCode
    }
})

//获取手机验证码
export let getSmsCode = (phoneNumber) => http.post('/sms/send', {
    phoneNumber
})

//手机验证码登入
export let smsLogin = code => http.post("/users/login?type=sms", {
    code
})

//获取日志
export const getLoginLogApi=(componentInstance,page=1,count=15)=>http.get("/getloginlog",{
    params:{
        page,
        count,
    }
})

//添加学员信息
export const addStuApi = (data) => http.post('/students/addstu', { ...data })

//获取学员信息
export const getStuListApi = (count = 10, page = 1, classes) => http.get("/students/getstulist", {
    params: {
        count,
        page,
        class: classes
    }
})

//编辑学员信息
export const editStuApi = (data) => http.post('/students/updatestu', {
    ...data
})

//删除学员信息
export const deleteStu = (sId) => http.get('/students/delstu', {
    params: {
        sId
    }
})

//获取班级列表
export const getClassesApi = () => http.get("/students/getclasses");

//搜索学员
export const searchStuApi = (page, key, count) => {
  //短路运算
  count = count || 10;
  key = key || "";
  page = page || 1;
  return http.get("/students/searchstu", {
    params: {
      page,
      count,
      key,
    },
  });
};

//支付
//获取订单信息
export const getOrderApi=()=>http.post('/order/get_order')

//获取vip产品
export const getVipListApi=()=>http.get('/product/get_product',{
     params:{
         category_id:'20210827165510715'
     }
})

//获取产品信息
export const getProductDetailApi=(product_id)=>http.get('/product/get_product',{
    params:{
        product_id,
    }
})

//获取下单商品数量
export const preOrderApi=(product_id,quantity)=>http.post('/order/pre_order',{
    quantity,
    product_id,
})

//获取订单详情
export const getOrderDetail = order_id => {
    console.log(order_id)
    return http.post('/order/get_order', { order_id })
}

//获取支付地址
export const pay = order_id => http.post("/pay/payment", { order_id })

//查询支付状态
export const queryPayStatus = order_id => http.get('/order/query_order_status', {
    params: {
        order_id
    }
})

//获取用户信息
export const getUserList=()=>http.get('/users/getAllUsers')

//期望课程数据

export const getexpectDataApi = () => http.get("/data/expect.json");

//折线图数据

export const getlineDataApi = () => http.get("/data/rate.json");

//任务进度数据

export const gettaskDataApi = () => http.get("/data/tarsk.json");
